package com.study.kt._01grammar._02oop

//运算符重载 +(a.plus(b)) - * / 区间..(a.rangeTo(b)) 都代表一个函数
fun main() {
    //通过运算符重载可以实现对象的 + - * /

    var teacher = Teacher()
    var heightTeacher = teacher++
    println("${heightTeacher.level}==>${heightTeacher.salary}")
}

class Teacher {
    var level = 1 //等级
    var salary = 100 //工资

    //要让Teacher可以进行++ 操作，就要实现inc方法，inc对应++操作符
    //使用operator表示要重载运算符 ++
    operator fun inc(): Teacher {
        level++
        salary += 100
        return this
    }
}